/*
 * Copyright (C) 2016  Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */


#include "PlanetWars2dRT-core/specific/model/ship_observers.h"


EXTERN_C_BEGIN


bool
ship_add_observer(ship_t* a_ship, const observer_t* an_observer)
{
  return observers_add(&a_ship->observers, an_observer);
}

bool
ship_remove_observer_without_order(ship_t* a_ship,
				   const observer_t* an_observer)
{
  return observers_remove_without_order(&a_ship->observers, an_observer);
}

bool
ship_remove_observer_with_order(ship_t* a_ship,
				const observer_t* an_observer)
{
  return observers_remove_with_order(&a_ship->observers, an_observer);
}

void
ship_remove_observers(ship_t* a_ship)
{
  observers_clear(&a_ship->observers);
}

void
ship_notify_observers(ship_t* a_ship, void* data)
{
  observers_notify(&a_ship->observers, a_ship, data);
}

size_t
ship_get_nb_observers(const ship_t* a_ship)
{
  return a_ship == NULL ? 0 : observers_get_nb(&a_ship->observers);
}


EXTERN_C_END
